ASCII Christmas Tree

Charlie Veniot 16th December 2022 at 12:46am
' BASIC Anywhere Machine program by Charlie Veniot
' based on the program by James D Jarvis (https://qb64phoenix.com/forum/showthread.php?tid=1284&pid=11640#pid11640)
'ascii X_mas trees
_Title "ASCII X_mas Trees"
declare sub treetri(tx, ty, th)
dim as integer lights(0 to 5)
lights(0) = 9 : lights(1) = 10 : lights(2) = 12 : lights(3) = 14 : lights(4) = 15 : lights(5) = 11

Randomize Timer
Do
    tmid = 40
    Color 14, 0
    Locate 3, tmid
    Print "X"
    treetri (tmid, 3, 5)
    treetri (tmid, 6, 7)
    treetri (tmid, 11, 8)
    Color 6, 0
    Locate 20, tmid: Print "#"
    Locate 21, tmid: Print "#"
    Color 15, 0


    tmid = 20
    Color 14, 0
    Locate 6, tmid: Print "x"
    treetri (tmid, 6, 4)
    treetri (tmid, 8, 6)
    treetri (tmid, 11, 8)
    Color 6, 0
    Locate 20, tmid: Print "#"
    Locate 21, tmid: Print "#"
    Color 15, 0

    tmid = 60
    Color 14, 0
    Locate 6, tmid: Print "x"
    treetri (tmid, 6, 4)
    treetri (tmid, 8, 6)
    treetri (tmid, 11, 8)
    Color 6, 0
    Locate 20, tmid: Print "#"
    Locate 21, tmid: Print "#"
    Color 15, 0
    _delay 0.5
Loop

Sub treetri (tx, ty, th)
    For y = 1 To th
        For x = tx - y + 1 To tx + y - 1
            Color 2, 0
            Locate y + ty, x: Print "*"
            Select Case Int(Rnd * 12)
                Case 1
                    Color lights(int(rnd*6)), 0
                    Locate y + ty, x: Print "x"
                Case 2
                    Color lights(int(rnd*6)), 0
                    Locate y + ty, x: Print "o"
            End Select
        Next x
    Next y
End Sub